<?php
class Address_Components extends CI_Model{
	public function __construct(){
		parent::__construct();
		$this->load->database();
	}
	
	public function insertComponent($component){
		if($this->checkExist($component['location_id'], $component['types'])){
			return false;
		}else{
			$this->db->insert('address_components',$component);
			return true;
		}
		
	}
	
	public function checkExist($location_id,$types){
		$this->db->where('location_id',$location_id);
		$this->db->where('types',$types);
		if($this->db->count_all_results('address_components') > 0){
			return TRUE;
		}else{
			return FALSE;
		}
	}

	public function deleteComponent($location_id){
		$this->db->where('location_id',$location_id);
		$this->db->delete('address_components');
		return true;
	}
}